#include <jni.h>
#include <string>
#include <android/log.h>
#include <queue>
#include <cmath>
#include <stdlib.h>
#include <map.hpp>

using namespace std;


void visit(int key, int value, bool isRed) {
    if(isRed) {
        __android_log_print(ANDROID_LOG_ERROR, "TAG", "key= %d, value= %d, color= %s", key, value, "红");
    } else {
        __android_log_print(ANDROID_LOG_ERROR, "TAG", "key= %d, value= %d, color= %s", key, value, "黑");
    }
}

extern "C"
JNIEXPORT jstring
JNICALL
Java_com_ndk_day42_MainActivity_stringFromJNI(
        JNIEnv *env,
        jobject /* this */) {

    map<int, int> *map = new ::map<int, int>();
    map->insert(3, 3);
    map->insert(2, 2);
    map->insert(1, 1);
    map->insert(4, 4);
    map->insert(5, 5);

    map->insert(-5, -5);
    map->insert(-15, 15);
    map->insert(-10, -10);
    map->insert(6, 6);
    map->insert(7, 7);

    map->levelTraverse(visit); // 层序打印输出

    std::string hello = "Hello from C++";
    return env->NewStringUTF(hello.c_str());
}

